package com.test.restaurant.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.test.restaurant.dao.DishTableDAO;
import com.test.restaurant.pojo.DishTable;
import com.test.restaurant.service.DishTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

import javax.annotation.PostConstruct;
import java.util.List;

/**
 * @author 徒有琴
 */
@Service//dubbo的注解，不是spring的，不要导错包
public class DishTableServiceImpl implements DishTableService {
    @Autowired
    private DishTableDAO dishTableDAO;

    @Override
    public List<DishTable> getTableList(String name) {
        System.out.println("aaaaaaa");
        return dishTableDAO.getTableList(name);
    }

    @Autowired
    private  RedisTemplate redisTemplate;

    @PostConstruct
    private void init(){
        List<DishTable> list=dishTableDAO.getTableList(null);
        redisTemplate.opsForValue().set("tables",list);
    }
}
